package com.artPreter.controller;


import com.artPreter.pojo.Artist;
import com.artPreter.pojo.ArtistRelative;
import com.artPreter.pojo.Depart;
import com.artPreter.pojo.Result;
import com.artPreter.pojo.dto.ArtistRelativeDTO;
import com.artPreter.pojo.dto.RelationArtistDTO;
import com.artPreter.service.IArtistRelativeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 艺术机构-艺术家关系表 前端控制器
 * </p>
 *
 * @author jarvis
 * @since 2024-11-15
 */
@RestController
@RequestMapping("/artistRelative")
public class ArtistRelativeController {

    @Autowired
    private IArtistRelativeService artworkService;


    /**
     * 获取机构下的艺术家
     * @param
     * @return
     */
    @PostMapping("/getList")
    public Result<List<ArtistRelative>> getList(@RequestBody RelationArtistDTO relationArtistDTO){

        Depart depart = new Depart();
        depart.setDepartId(relationArtistDTO.getDepartId());
        List<ArtistRelative> list = artworkService.getList(depart);
        return Result.success(list);
    }

    /**
     * 根据艺术家id获取机构关系
     * @param artist
     * @return
     */
    @PostMapping("/getListByArtistId")
    public Result<List<ArtistRelativeDTO>> getListByArtistId(@RequestBody Artist artist){
        List<ArtistRelativeDTO> list = artworkService.getListByArtistId(artist);
        return Result.success(list);
    }

    /**
     * 保存机构下--艺术家关系
     * @param relationArtistDTO
     * @return
     */
    @PostMapping("/saveRelation")
    public Result<List<ArtistRelative>> save(@RequestBody RelationArtistDTO relationArtistDTO){
        List<ArtistRelative> list = artworkService.saveRelation(relationArtistDTO);
        return Result.success(list);
    }
}
